package com.zyw.service.user.impl;

import com.zyw.entity.User;
import com.zyw.mapper.user.UserMapper;
import com.zyw.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Set;

@Service
@Slf4j
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public User findByUsername(String username) {
        return userMapper.findByUsername(username);
    }

    @Override
    public Set<String> findRolesByUsername(String username) {
        return userMapper.findRolesByUsernaem(username);
    }

    @Override
    public Set<String> findPermissionsByRoles(Set<String> roleNames) {
        HashMap<String,Object> map = new HashMap<>();
        map.put("set",roleNames);
        return userMapper.findPermissionsByRoles(map);
    }

    @Override
    public LinkedHashMap<String, String> findShiroFilterChain() {
        return userMapper.findShiroFilterChain();
    }

}
